package com.util;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.zip.GZIPOutputStream;

public class NrmUtil {
	public static void CompressNrmFile(String inFileName){
		String outFileName = inFileName+".gz";
		GZIPOutputStream out = null;
		FileInputStream in = null;
		try {
			out = new GZIPOutputStream(new FileOutputStream(outFileName));
			in = new FileInputStream(inFileName);
			byte[] buf = new byte[1024];
			int len;
			while((len = in.read(buf)) > 0) {
				out.write(buf, 0, len);
			}
			out.finish();
		} catch (Exception e) {
			System.exit(1);
			e.printStackTrace();
		}finally{
			try {
				in.close();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
	}
	
	public static String formatCurrentDate(){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HHmm");
		String currentDateStr = sdf.format(new Date());
		return currentDateStr;
	}
	
	public static String formatStrToDate(String str)throws Exception{
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HHmm");
		String dateStr = sdf.format(sdf.parse(str));
		return dateStr;
	}
	
	public static void main(String[] args) throws Exception{
		NrmUtil.formatCurrentDate();
	}
}
